//
//  UITextView+preSelectRange.swift
//  chat
//
//  Created by 崔世强 on 2024/7/26.
//  Copyright © 2024 崔世强. All rights reserved.
//

import Foundation
import UIKit


extension UITextView {
    private struct Keys { static var preSelectedRange = "kpreSelectedRange" }
    
    var preTextSelectedRange: NSRange? {
        get {
            if let aValue = objc_getAssociatedObject(self, &Keys.preSelectedRange) as? NSRange {
                return aValue
            } else {
                return nil
            }
        }
        set {
            objc_setAssociatedObject(self, &Keys.preSelectedRange, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
}
